/**********************************************************************/
/* UninstallCommon.SQL - SCHEMA REVAMP VERSION                        */
/*                                                                    */
/* Remove the common tables, triggers and stored procedures necessary */
/* for supporting the aspnet feature of ASP.Net                       */
/*                                                                    */
/* Copyright Microsoft, Inc. 2003                                     */
/* All Rights Reserved.                                               */
/*                                                                    */
/**********************************************************************/

PRINT '-----------------------------------------'
PRINT 'Starting execution of UninstallCommon.SQL'
PRINT '-----------------------------------------'
GO

SET QUOTED_IDENTIFIER OFF -- We don't use quoted identifiers
SET ANSI_NULLS ON         -- We don't want (NULL = NULL) == TRUE
GO
SET ANSI_PADDING ON
GO

USE [aspnetdb]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[Users]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [aspnet].[Users]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[Applications]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [aspnet].[Applications]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[SchemaVersions]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [aspnet].[SchemaVersions]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[Applications_CreateApplication]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [aspnet].[Applications_CreateApplication]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[Users_CreateUser]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [aspnet].[Users_CreateUser]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[Users_DeleteUser]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [aspnet].[Users_DeleteUser]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[Setup_RestorePermissions]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [aspnet].[Setup_RestorePermissions]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[Setup_RemoveAllRoleMembers]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [aspnet].[Setup_RemoveAllRoleMembers]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[RegisterSchemaVersion]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [aspnet].[RegisterSchemaVersion]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[UnRegisterSchemaVersion]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [aspnet].[UnRegisterSchemaVersion]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[CheckSchemaVersion]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [aspnet].[CheckSchemaVersion]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[AnyDataInTables]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [aspnet].[AnyDataInTables]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[ApplicationsView]') AND OBJECTPROPERTY(id, N'IsView') = 1)
DROP VIEW [aspnet].[ApplicationsView]

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[aspnet].[UsersView]') AND OBJECTPROPERTY(id, N'IsView') = 1)
DROP VIEW [aspnet].[UsersView]

IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = N'aspnet')
DROP SCHEMA aspnet
GO

PRINT '------------------------------------------'
PRINT 'Completed execution of UninstallCommon.SQL'
PRINT '------------------------------------------'
